
package com.platform.modules.platform.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.platform.common.annotation.SysLog;
import com.platform.common.utils.RestResponse;
import com.platform.modules.platform.entity.PlatformColumnEntity;
import com.platform.modules.platform.service.PlatformColumnService;
import com.platform.modules.sys.controller.AbstractController;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * 首页底部菜单，个人中心栏目设置表Controller
 *
 * @author 
 * @date 2022-09-21 08:59:43
 */
@RestController
@RequestMapping("platform/column")
public class PlatformColumnController extends AbstractController {
    @Autowired
    private PlatformColumnService platformColumnService;

    /**
     * 查看所有列表
     *
     * @param params 查询参数
     * @return RestResponse
     */
    @RequestMapping("/queryAll")
    @RequiresPermissions("platform:column:list")
    public RestResponse queryAll(@RequestParam Map<String, Object> params) {
        List<PlatformColumnEntity> list = platformColumnService.queryAll(params);

        return RestResponse.success().put("list", list);
    }

    /**
     * 分页查询首页底部菜单，个人中心栏目设置表
     *
     * @param params 查询参数
     * @return RestResponse
     */
    @GetMapping("/list")
    @RequiresPermissions("platform:column:list")
    public RestResponse list(@RequestParam Map<String, Object> params) {
        Page page = platformColumnService.queryPage(params);

        return RestResponse.success().put("page", page);
    }

    /**
     * 根据主键查询详情
     *
     * @param id 主键
     * @return RestResponse
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("platform:column:info")
    public RestResponse info(@PathVariable("id") String id) {
        PlatformColumnEntity platformColumn = platformColumnService.getById(id);

        return RestResponse.success().put("column", platformColumn);
    }

    /**
     * 新增首页底部菜单，个人中心栏目设置表
     *
     * @param platformColumn platformColumn
     * @return RestResponse
     */
    @SysLog("新增首页底部菜单，个人中心栏目设置表")
    @RequestMapping("/save")
    @RequiresPermissions("platform:column:save")
    public RestResponse save(@RequestBody PlatformColumnEntity platformColumn) {

        platformColumnService.add(platformColumn);

        return RestResponse.success();
    }

    /**
     * 修改首页底部菜单，个人中心栏目设置表
     *
     * @param platformColumn platformColumn
     * @return RestResponse
     */
    @SysLog("修改首页底部菜单，个人中心栏目设置表")
    @RequestMapping("/update")
    @RequiresPermissions("platform:column:update")
    public RestResponse update(@RequestBody PlatformColumnEntity platformColumn) {

        platformColumnService.update(platformColumn);

        return RestResponse.success();
    }

    /**
     * 根据主键删除首页底部菜单，个人中心栏目设置表
     *
     * @param ids ids
     * @return RestResponse
     */
    @SysLog("删除首页底部菜单，个人中心栏目设置表")
    @RequestMapping("/delete")
    @RequiresPermissions("platform:column:delete")
    public RestResponse delete(@RequestBody String[] ids) {
        platformColumnService.deleteBatch(ids);

        return RestResponse.success();
    }
}
